home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / src_1218.zip / DEVPARAM.C < prev    next >
C/C++ Source or Header  |  1991-09-21  |  1KB  |  74 lines

  1. #include <string.h>
  2. #include <ctype.h>
  3. #include "global.h"
  4. #include "devparam.h"
  5.  
  6. struct param {
  7.     int number;
  8.     char *name;
  9. };
  10. static struct param Parms[] = {
  11.     PARAM_DATA,    "Data",
  12.     PARAM_TXDELAY,    "TxDelay",
  13.     PARAM_PERSIST,    "Persist",
  14.     PARAM_SLOTTIME,    "SlotTime",
  15.     PARAM_TXTAIL,    "TxTail",
  16.     PARAM_FULLDUP,    "FullDup",
  17.     PARAM_HW,    "Hardware",
  18.     PARAM_MUTE,    "TxMute",
  19.     PARAM_DTR,    "DTR",
  20.     PARAM_RTS,    "RTS",
  21.     PARAM_SPEED,    "Speed",
  22.     PARAM_ENDDELAY,    "EndDelay",
  23.     PARAM_GROUP,    "Group",
  24.     PARAM_IDLE,    "Idle",
  25.     PARAM_MIN,    "Min",
  26.     PARAM_MAXKEY,    "MaxKey",
  27.     PARAM_WAIT,    "Wait",
  28.     PARAM_DOWN,    "Down",
  29.     PARAM_UP,    "Up",
  30.     PARAM_BLIND,    "Blind",
  31.     PARAM_RETURN,    "Return",
  32.     -1,        NULLCHAR,
  33. };
  34.     
  35. /* Convert a packet radio interface control token into a number
  36.  * Used by the various ioctl routines and by KISS TNC commands
  37.  */
  38. int
  39. devparam(s)
  40. char *s;
  41. {
  42.     int len;
  43.     struct param *sp;
  44.  
  45.     len = strlen(s);
  46.     if(isdigit(s[0]))
  47.         return atoi(s);
  48.  
  49.     sp = &Parms[0];
  50.     while(sp->number != -1){
  51.         if(strnicmp(s,sp->name,len) == 0)
  52.             return sp->number;
  53.         sp++;
  54.     }        
  55.     return -1;
  56. }
  57.  
  58. char *
  59. parmname(n)
  60. int n;
  61. {
  62.     struct param *sp;
  63.  
  64.     sp = &Parms[0];
  65.     while(sp->number != -1){
  66.         if(sp->number == n)
  67.             return sp->name;
  68.         sp++;
  69.     }        
  70.     return NULLCHAR;
  71. }
  72.  
  73.  
  74.